package com.example.ruleenginelearning.example.engine;

import com.example.ruleenginelearning.example.model.Order;

import java.util.ArrayList;
import java.util.List;

public class OrderRuleEngine {

    private final List<OrderRule> rules = new ArrayList<>();

    public void addRule(OrderRule rule) {
        rules.add(rule);
    }

    public void process(Order order) {
        for (OrderRule rule : rules) {
            if (rule.evaluate(order)) {
                rule.execute(order);
                return;
            }
        }
        System.out.println("未找到匹配规则的状态: " + order.getStatus());
    }
}
